package com.hooper.redisdemo.controller;

import com.hooper.redisdemo.domain.User;
import com.hooper.redisdemo.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Set;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2023/02/24/13:27
 */
@RestController
@RequestMapping("/user/")
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/followOrNot/{follow}/{target}")
    public String followOrOnt(@PathVariable Long follow, @PathVariable Long target) {
        return userService.followOrUnfollow(follow, target);
    }

    @GetMapping("mutual/list/{targetOne}/{targetTwo}")
    public Set<User> getMutualFollowList(@PathVariable Long targetOne, @PathVariable Long targetTwo) {
        return userService.getMutualFollows(targetOne, targetTwo);
    }

    @GetMapping("/sign/{userId}/{dayOfMonth}")
    public String signIn(@PathVariable Integer dayOfMonth, @PathVariable Long userId){
        return userService.userSignIn(userId,dayOfMonth);
    }

    @GetMapping("/count/{userId}")
    public String getCount(@PathVariable Long userId){
        return userService.consecutiveSignDays(userId);
    }
}
